Network analysis & Graph Theory.
Summary of steps for applying Dijkstra's algorithm.
Dijkstra's algorithm finds the shortest path through a network.
The steps to follow to find the shortest path between vertex A and vertex F are summarised below.
Step 1: | Write out the vertices in a row - starting with the starting vertex (A) and ending with the finishing vertex (F). |
|
|||||||||||||||||||||||||||||||||||
Step 2: | Write the letter for the start in a column starting before row 1. |
|
|||||||||||||||||||||||||||||||||||
Step 3: | Record in the first row of the table the distances from A to B and from A to D because they represent a step of 1 from vertex A. |
|
|||||||||||||||||||||||||||||||||||
Step 4: | Select the vertex with the minimum distance - here B has 3 - and then write B in the next row below A with the distance from A in brackets. |
|
|||||||||||||||||||||||||||||||||||
Step 5: | Add the value you wrote after the B to each of the distances to the vertices linked to B and record these in the same row in the appropriate column. For example B to C is 9 so add that to the 3 in brackets after B. |
|
|||||||||||||||||||||||||||||||||||
Step 6: | Check each column to determine if the ABD = 10 but A direct to D was 5 - so discard the 10. A to D is shortest so include D in the first column of the next row. |
|
|||||||||||||||||||||||||||||||||||
Step 7: | The distance A to D to E (5 + 7=12) is larger than the distance A to B to E (3+8=11) so discard DE. The next shortest distance is from B to E. Write E in the first column with its distance (11). |
|
|||||||||||||||||||||||||||||||||||
Step 8: | We can’t go backwards from E so the only vertex remaining is F. Add to weight to E (=11) to the EF weight to obtain the total weight. |
|
|||||||||||||||||||||||||||||||||||
So the shortest path from A to F is: A B E F and its length is 17 (11 + 6). |